package think.anno;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.nio.file.attribute.UserPrincipalLookupService;
import java.util.List;

import org.junit.Test;

public class PasswordUtil {
	@Test
	@UseCase(id = 1,description="验证密码")
	public boolean passwordVolidate(String password){
		return password.matches("[0-9,a-z]");
	}
	@Test
	public void dd(){
		System.out.println("test");
	}
	
	
	@UseCase(id = 2,description = "加密密码")
	public String  encryptPassword(String password){
		return new StringBuilder(password).reverse().toString();
	}

	@UseCase(id=3,description = "密码是否存在" )
	public boolean checkPassword(List<String> passList,String password){
		return !passList.contains(password);
	}
	
	
	public static void getAnno(Class<?> clazz){
		Method [] methods = clazz.getDeclaredMethods();//获取类中所用的发方法
		
		for(Method me :methods){
			System.out.println(me.getName());
			UseCase use= me.getAnnotation(UseCase.class);//获取方法上的usercase注解
			if(use!=null){
				System.out.println(use.id());
			}
		}
		
		
	}
	public static void main(String[] args) {
		getAnno(PasswordUtil.class);
		
	}
}
